# -*- coding: utf-8 -*-
"""
Coroutines and concurrency/Tornado Queues/test02.py
"""
import asyncio
from tornado import queues
from tornado import gen

q = queues.Queue(maxsize=5)


def no_wait_consumer():
    """
    消费者
    :return:
    """
    item = q.get_nowait()
    print(f'Doing work on {item}')


async def producer():
    """
    生产者
    :return:
    """
    for item in range(10):
        await q.put(item)
        print(f'Put {item}')


async def main():
    no_wait_consumer()
    await producer()


if __name__ == '__main__':
    asyncio.run(main())
